package com.yh.config;

import io.minio.MinioClient;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 文件服务器minio客户端的自动配置类
 *
 * @Author yuhuan
 * @Date 2022/3/21
 */
@Configuration
@EnableConfigurationProperties(MinioProperties.class)
public class MinioAutoConfiguration {
    @Bean
    public MinioClient minioClient(MinioProperties minioProperties) {
        /* @secure 是不是要使用"https" */
        MinioClient minioClient = MinioClient.builder()
                .endpoint(minioProperties.getMinioHost(), minioProperties.getMinioPort(), false)
                .credentials(minioProperties.getMinioUserName(), minioProperties.getMinioPassWord())
                .build();
        return minioClient;
    }
}
